package com.roger.myHome.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.roger.myHome.domain.TbDict;
import com.roger.myHome.mapper.DictMapper;
import com.roger.myHome.service.DictService;
import com.roger.myHome.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DictServiceImpl implements DictService {
    @Resource
    private DictMapper dictMapper;

    @Override
    public String loadCombobox(String type, Long parentId) {
        QueryWrapper<TbDict> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("type", type);
        queryWrapper.eq("parent_id", parentId);
        List<TbDict> list = dictMapper.selectList(queryWrapper);

        return StringUtils.listToJson(list);
    }
}
